<?php

class Application_Form_Addprinter extends Zend_Form {

    public function init() {
	
	$cartridges = $this->getCartridgesArray();
	
	$this->setAction('/printers/addprinter');
	$this->setMethod('post');

	$this->addElement('text', 'name', array(
	    'label' => 'Имя принтера: ',
	    'required' => true,
	    'maxLength' => 255
	));

	$this->addElement('textarea', 'description', array(
	    'label' => 'Описание: ',
	    'required' => false,
	    'maxlength' => 255,
	    'rows' => 5,
	    'cols' => 40
	));
	
	$this->addElement('text', 'ip', array(
	    'label' => 'IP адрес: ',
	    'required' => false,
	    'maxLength' => 255
	));
	
	$this->addElement('text', 'netname', array(
	    'label' => 'Имя в интернете: ',
	    'required' => false,
	    'maxLength' => 255
	));
	
	$this->addElement('select', 'colorc', array(
	    'label' => 'Голубой картридж: ',
	    'required' => false,
	    'multiOptions'=> $cartridges,
	));
	
	$this->addElement('select', 'colorm', array(
	    'label' => 'Пурпурный картридж: ',
	    'required' => false,
	    'multiOptions'=> $cartridges,
	));
	
	$this->addElement('select', 'colory', array(
	    'label' => 'Желтый картридж: ',
	    'required' => false,
	    'multiOptions'=> $cartridges,
	));
	
	$this->addElement('select', 'colork', array(
	    'label' => 'Черный картридж: ',
	    'required' => false,
	    'multiOptions'=> $cartridges,
	));


	$this->addElement('submit', 'submit', array(
	    'label' => 'Добавить'
	));
    }
    
    protected function getCartridgesArray(){
	$printersMapper = new Application_Model_Printers;
	$result = array('0' => 'нет');
	$catrtidges = $printersMapper->listCartridges();
	foreach ($catrtidges as $c){
	    $result[$c->getName()] = $c->getName();
	}
	return $result;
    }

}

